package com.sky.task;

import com.sky.webSocket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

//@Component
@Slf4j
public class MyTask {
    @Autowired
    private WebSocketServer webSocketServer;
    @Scheduled(cron = "0/5 * * * * ?")
    public void test(){
//        System.out.println(LocalDateTime.now());
//        LocalDateTime now = LocalDateTime.now();
//        System.out.println(now);
//        LocalDateTime localDateTime = now.minusMinutes(15);
//        System.out.println(localDateTime);
        webSocketServer.sendToAllClient("这是来自服务端的消息：" + DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalDateTime.now()));
    }
}
